import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
// import path from 'path';
// import { fileURLToPath, URL } from "url";
import {fileURLToPath, URL} from 'node:url'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
      vue(),
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
    resolve: {
        alias: {
            // '@': path.resolve(__dirname, './src'), // 将 '@' 映射到 src 目录
            "@": fileURLToPath(new URL("./src", import.meta.url)),
            // { find: '@', replacement: path.resolve(__dirname, './src') ｝
            // { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
            // { find: '@assets', replacement: fileURLToPath(new URL('./src/shared/assets', import.meta.url)) },
            // { find: '@cmp', replacement: fileURLToPath(new URL('./src/shared/cmp', import.meta.url)) },
            // { find: '@stores', replacement: fileURLToPath(new URL('./src/shared/stores', import.meta.url)) },
            // { find: '@use', replacement: fileURLToPath(new URL('./src/shared/use', import.meta.url)) },
        },
    },

});